package org.mao.coque.websocket;

import javax.servlet.http.HttpSession;
import javax.websocket.HandshakeResponse;
import javax.websocket.server.HandshakeRequest;
import javax.websocket.server.ServerEndpointConfig;
import javax.websocket.server.ServerEndpointConfig.Configurator;

import org.apache.log4j.Logger;

public class WebSocketConfigurator extends Configurator {

	private final static Logger logger = Logger.getLogger(WebSocketConfigurator.class);

	@Override
	public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request, HandshakeResponse response) {
		// TODO Auto-generated method stub
		HttpSession httpSession = (HttpSession) request.getHttpSession();
		logger.info("modifyHandshake: " + httpSession);
		logger.info("modifyHandshake: " + httpSession.getAttribute("nickName"));
		sec.getUserProperties().put(HttpSession.class.getName(), httpSession);
	}
}
